<template>
  <div class="count">
    <div class="top">
      <div class="title">
        <div>数据统计</div>
        <img src="@/views/screen/images/dataScreen-title.png" alt="">
      </div>
    </div>
    <div class="chart" ref="chart"></div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import * as echarts from 'echarts';
const chart = ref()
onMounted(() => {
  const myChart = echarts.init(chart.value)
  let option = {
    legend: {
      data: ['消费能力', '收入能力', '事业能力'],
      show: true,
      orient: 'vertical',
      right: 5,
      textStyle: {
        color: '#fff',
        fontSize: 15
      },
    },
    grid: {
      left: '3%',
      containLabel: true
    },
    tooltip: {
      // trigger: 'axis',
      axisPointer: {
        type: 'cross',
        label: {
          backgroundColor: '#6a7985'
        }
      }
    },
    radar: {
      // shape: 'circle',
      indicator: [
        { name: '12-18岁', max: 6500 },
        { name: '18-23岁', max: 16000 },
        { name: '23-26岁', max: 30000 },
        { name: '26-30岁', max: 38000 },
        { name: '30-40岁', max: 52000 },
        { name: '40岁以上', max: 25000 }
      ],
      radius: 80,//缩放
      center: ['40%', '45%'],//位置
    },
    series: [
      {
        name: '',
        type: 'radar',
        data: [
          {
            value: [4200, 3000, 20000, 35000, 50000, 18000],
            name: '消费能力',
            label: {
              // show: true,
              formatter: function (params: { value: any; }) {
                return params.value;
              }
            },
            areaStyle: {
              color: new echarts.graphic.RadialGradient(0.1, 0.6, 1, [
                {
                  color: 'rgba(255, 25, 12, 0.1)',
                  offset: 0
                },
                {
                  color: 'rgba(255, 45, 14, 0.9)',
                  offset: 1
                }
              ])
            }
          },
          {
            value: [5000, 14000, 28000, 26000, 42000, 21000],
            name: '收入能力',
            label: {
              // show: true,
              formatter: function (params: { value: any; }) {
                return params.value;
              }
            },
            areaStyle: {
              color: new echarts.graphic.RadialGradient(0.1, 0.6, 1, [
                {
                  color: 'rgba(255, 145, 124, 0.1)',
                  offset: 0
                },
                {
                  color: 'rgba(255, 145, 124, 0.9)',
                  offset: 1
                }
              ])
            }
          },
          {
            value: [1000, 10000, 22000, 38000, 30000, 20000],
            name: '事业能力',
            label: {
              // show: true,
              formatter: function (params: { value: any; }) {
                return params.value;
              }
            }
          }
        ]
      }
    ]
  };
  myChart.setOption(option)
})
</script>

<style lang="scss" scoped>
.count {
  width: 100%;
  height: 310px;
  background: url(@/views//screen/images/dataScreen-main-rt.png)no-repeat;
  background-size: cover;

  .top {
    .title {
      color: white;
      font-size: 22px;
      padding-left: 10px;
    }
  }

  .chart {
    width: 100%;
    height: 280px;
  }
}
</style>
